package com.example.index.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.index.R
import com.example.index.adapter.foo.Foo
import me.drakeet.multitype.ItemViewBinder

class FooViewBinder : ItemViewBinder<Foo, FooViewBinder.ViewHolder>() {

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        return ViewHolder(inflater.inflate(R.layout.demo_item, parent, false))
    }

    override fun onBindViewHolder(holder: ViewHolder, item: Foo) {
//        holder.fooView.text = item.value
//        Log.d("ItemViewBinder API", "position: ${getPosition(holder)}")
//        Log.d("ItemViewBinder API", "items: $adapterItems")
//        Log.d("ItemViewBinder API", "adapter: $adapter")
//        Log.d("More", "Context: ${holder.itemView.context}")
    }

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val fooView: TextView = itemView.findViewById(R.id.item_name)

        val marker: TextView = itemView.findViewById(R.id.corner_marker)

        fun bind(foo: Foo) {
            fooView.text = foo.value
            marker.visibility = View.GONE
        }
    }
}